﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using EjemploSVN.Models;

namespace EjemploSVN.DataAccess
{
    public class ModelContext : DbContext
    {

        public DbSet<Student> Students { get; set; }

        public DbSet<Country> Countries { get; set; }

        public ModelContext()
            : base("EjemploSVN")
        { 
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
        }
    }

    public class CustomInitializer : DropCreateDatabaseIfModelChanges<ModelContext>
    {

        protected override void Seed(ModelContext context)
        {
            base.Seed(context);
            context.Countries.Add(new Country() { Name = "Argentina" });
            context.Countries.Add(new Country() { Name = "Uruguay" });
            context.Countries.Add(new Country() { Name = "Chile" });
            context.Countries.Add(new Country() { Name = "Brasil" });
            context.SaveChanges();
        }
    }
}
